package model

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Phone        string `gorm:"type:char(11);not null;index;commit:'手机号'"`
	Password     string `gorm:"type:char(32);not null;commit:'密码'"`
	NickName     string `gorm:"type:varchar(50); not null;commit:'昵称'"`
	Status       int64  `gorm:"type:int;default:1;commit:'0-异常,1-正常'"`
	MemberStatus int64  `gorm:"type:int;default:0;commit:'0-非会员,1-会员'"`
}

func (u *User) GetPhoneByPhone(db *gorm.DB, phone string) error {
	err := db.Where("phone=?", phone).Find(&u).Error
	return err
}
func (u *User) CreateUser(db *gorm.DB) error {
	err := db.Create(&u).Error
	return err
}
